Description:
The compiler does not produce an error or warning when not all of the enumeration constants are handled in a switch statement and no default branch is provided. Although in many situations it is desired behavior, it can also be programmer error; therefore, ECNHS produces error messages in these cases. To eliminate this message and to clarify your code, add the explicit default branch.
Incorrect:
type
Colors = (Red, Green, Blue);
...
function GetColor(c: Colors):integer;
begin
result := 0;
case c of
Colors.Red:
result := $FF0000;
Colors.Green:
result := $FF00;
end;
end;
Correct:
type
Colors = (Red, Green, Blue);
...
function GetColor(c: Colors):integer;
begin
result := 0;
case c of
Colors.Red:
result := $FF0000;
Colors.Green:
result := $FF00;
Colors.Blue:
result := $FF;
end;
end;